package entity;

public class Teacher extends Person {
    private Course teachingCourse;

    // 子类构造方法，使用super调用父类构造方法
    public Teacher(String id, String name, String gender, Course teachingCourse) {
        super(id, name, gender);
        this.teachingCourse = teachingCourse;
    }

    // 教师开课方法
    public void offerCourse(Course course) {
        this.teachingCourse = course;
        System.out.println(name + "老师开设了课程: " + course.getCourseName());
    }

    // 重写父类方法，打印教师工作单
    @Override
    public void displayInfo() {
        super.displayInfo();
        if (teachingCourse != null) {
            System.out.println("所授课程: " + teachingCourse.getCourseName());
        } else {
            System.out.println("暂无授课");
        }
    }

    public Course getTeachingCourse() { return teachingCourse; }
}